<!DOCTYPE html>
<html>
<head>
	<title>新闻咨询注册页面</title>
	<meta charset="utf-8">
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<link rel="stylesheet" type="text/css" href="css/news.css">
</head>
<body>
	<div id="top">
	    <img class="goback1"  src="img/back.png" style="position: absolute;width: 42px;left: 2%;top: 10%;"/>
		<label>Google News</label>    
	</div>
	<div id="center">
		<img id="regtouxiang" src="">

		<div id="reg_text">
			<input id="usernamae" type="text" name="" placeholder="请输入用户名"><br>
			<input style="width: 80%;height: 50px;margin-top: 20px;
	        margin-left: 10%;border:0px;border-radius: 5px;" id="password" type="password" name="" placeholder="请输入密码"><br>
			<input id="shuoshuo" type="text" name="" placeholder="个性签名"><br>
			<input id="email" type="text" name="" placeholder="请输入邮箱"><br>
		</div>
		
	</div>
	<div id="foot">
		<input id="regbtn" type="button" name="" value="注册">
	</div>

	<script src="js/jquery-3.2.1.js"></script>
	<script type="text/javascript">
		$arr=["image2/c1.jpg","image2/c2.jpg","image2/c3.jpg","image2/c4.jpg","image2/c5.jpg"];
		
		$(function(){
			$suiji=Math.ceil(Math.random()*4)
            $("#regtouxiang").attr('src',$arr[$suiji]);
            
			$("#regbtn").on("click",function(){

				$.ajax({
					type: "get",
					url: "http://127.0.0.1/news/reg1.php",
					async: true,
					data: {
						touxiang: $("img").attr('src'),
						name:$("#usernamae").val(),
						pass:$("#password").val(),
						shuoshuo:$("#shuoshuo").val(),
						email:$("#email").val()
					},
					dataType:"json",
					success: function(data) {
						if(data['code']==1){
							window.location.href="news_login.html";
						}else if(data['code']==-10006){
							alert("用户名已存在");
						}
						else{
							alert("注册失败,请检查网络连接");
						}
					}
				});

			})
			$(".goback1").on("click",function(){
				window.history.back(-1);
			})
		});
	</script>
</body>
</html>
